<?php
class MY_Controller extends CI_Controller {
    public function __construct() {
       parent::__construct();
       // load user agent and check if IE < 9
       // $this->output->cache(10);
       // $this->output->enable_profiler(TRUE);
         
         $this->load->library('user_agent');
         if($this->agent->browser() == "Internet Explorer"  )
         {
            if( $this->agent->version() < 9)
            {
              die("Guncel olmayan Internet Explorer kullaniyorsunuz<br>
                   <a href='https://www.google.com/intl/tr/chrome/'>Chrome </a>
                   indirmenizi tavsiye ederiz ");
            }
         }
         
        // Session ile sepeti doldur bosalt 
        if($this->session->userdata('logged_in'))
        {
                $data['sepetim'] = $this->sepetim_model->fill_cart_by_customer_id($this->session->userdata('user_id'));
                $sepet_session = array(
                    'items' => $data['sepetim']['items'],
                    'products' => $data['sepetim']['products'],
                    'total'     => $data['sepetim']['total'],
                    'cart_id' => $data['sepetim']['cart_id']
                    
                );
            $this->session->set_userdata($sepet_session);
         }
         else
         {
            
    
                $data['sepetim'] = $this->sepetim_model->fill_cart_by_session_id( $this->session->userdata['session_id']);
                
                $sepet_session = array(
                    'items' => $data['sepetim']['items'],
                    'products' => $data['sepetim']['products'],
                    'total'     => $data['sepetim']['total'],
                    'cart_id' => $data['sepetim']['cart_id']
                    
                );
          $this->session->set_userdata($sepet_session);         
         }
    }
}

?>